<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">
		<link rel="icon" href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/favicon.ico">
		<link rel="canonical" href="https://getbootstrap.com/docs/3.4/examples/dashboard/">
		<title>Dashboard Template for Bootstrap</title>
		<link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/dist/css/bootstrap.min.css"
			rel="stylesheet">
		<link
			href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/css/ie10-viewport-bug-workaround.css"
			rel="stylesheet">
		<link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/examples/dashboard/dashboard.css"
			rel="stylesheet">
		<script
			src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/js/ie-emulation-modes-warning.js">
		</script>
		<script src="moz-extension://182e00ce-9849-4936-a5b4-b8d720db79f8/assets/prompt.js"></script>
	</head>
	<body>

		<nav class="navbar navbar-inverse navbar-fixed-top">
			<div class="container-fluid">
				<div class="navbar-header">
					<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
						aria-expanded="false" aria-controls="navbar">
						<span class="sr-only">Toggle navigation</span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>
					<a class="navbar-brand" href="#">在线书城</a>
				</div>
				<div id="navbar" class="navbar-collapse collapse">
					<ul class="nav navbar-nav navbar-right">
						<li><a href="#" id="isLogin">个人中心</a></li>
						<li><a href="#">退出系统</a></li>
						<li><a href="#">帮助</a></li>
					</ul>
					<form class="navbar-form navbar-right">
						<input type="text" class="form-control" placeholder="Search...">
					</form>
				</div>
			</div>
		</nav>

		<div class="container-fluid">
			<div class="row">
				<div class="col-sm-3 col-md-2 sidebar">
					<ul class="nav nav-sidebar">
						<li class="active"><a href="#">用户管理 <span class="sr-only">(current)</span></a></li>
						<li><a href="#">Reports</a></li>
						<li><a href="#">Analytics</a></li>
						<li><a href="#">Export</a></li>
					</ul>
					<ul class="nav nav-sidebar">
						<li><a href="bookManager.html">图书管理</a></li>
						<li><a href="">Nav item again</a></li>
						<li><a href="">One more nav</a></li>
						<li><a href="">Another nav item</a></li>
						<li><a href="">More navigation</a></li>
					</ul>
					<ul class="nav nav-sidebar">
						<li><a href="">个人中心</a></li>
						<li><a href="">One more nav</a></li>
						<li><a href="">Another nav item</a></li>
					</ul>
				</div>
				<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

					<h2 class="sub-header">用户管理</h2>
					<div class="table-responsive">
						<table class="table table-striped">
							<thead>
								<tr>
									<th>序号</th>
									<th>用户名</th>
									<th>密码</th>
									<th>年龄</th>
									<th>邮箱</th>
									<th>电话</th>
									<th>个人介绍</th>
									<th>验证码</th>
									<th>状态</th>
									<th>角色</th>
									<th>注册时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody id="tbajax">


							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>

		<!-- Bootstrap core JavaScript
	    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->



	</body>
	<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"
		integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous">
	</script>
	<script>
		window.jQuery || document.write(
			'<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/js/vendor/jquery.min.js"><\/script>'
			)
	</script>
	<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/dist/js/bootstrap.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/js/vendor/holder.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/js/ie10-viewport-bug-workaround.js">
	</script>
	<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>

	<script>
	$(function (){
		$(function (){
			$.ajax({
				async: true,
				url: "./adminlogin.do",
				type: "get",
				data:{
					action: "adminKeepLogin"
				},
				success: function (data) {
					if(data==null||data==""||data==undefined){
						$('#isLogin').text("个人中心");
						return;
					}
					var data1 = JSON.parse(data);
					$('#isLogin').text(data1);
					$($('#isLogin')[0].parentElement).addClass("active");
				},
				dataType: "text"
			});

			$.ajax({
				async: true,
				url: "./user.do",
				type: "get",
				data:{
					action: "showAllUser"
				},
				success: function (data) {
					if(data==null||data==""||data==undefined){
						$('#tbajax tbody').text("无用户数据");
						return;
					}
					var data1 = JSON.parse(data);
					for (let i = 0; i <data1.length ; i++) {
						var $tr=$('<tr></tr>');
						$tr.appendTo($('#tbajax '));
						var $td1=$('<td></td>');
						$td1.appendTo($tr);
						$td1.text(i+1);

						
						var $td2=$('<td></td>');
						$td2.insertAfter($td1);
						$td2.text(data1[i].username);

						var $td3=$('<td></td>');
						$td3.insertAfter($td2);
						$td3.text(data1[i].password);

						var $td4=$('<td></td>');
						$td4.insertAfter($td3);
						$td4.text(data1[i].gender);

						var $td5=$('<td></td>');
						$td5.insertAfter($td4);
						$td5.text(data1[i].email);

						var $td6=$('<td></td>');
						$td6.insertAfter($td5);
						$td6.text(data1[i].telephone);

						var $td7=$('<td></td>');
						$td7.insertAfter($td6);
						$td7.text(data1[i].introduce);

						var $td8=$('<td></td>');
						$td8.insertAfter($td7);
						$td8.text(data1[i].activeCode);


						var $td9=$('<td></td>');
						$td9.insertAfter($td8);
						$td9.text(data1[i].state);

						var $td10=$('<td></td>');
						$td10.insertAfter($td9);
						$td10.text(data1[i].role);

						var $td11=$('<td></td>');
						$td11.insertAfter($td10);
						$td11.text(data1[i].registTime);

						var $td12=$('<td></td>');
						$td12.insertAfter($td11);
						$td12.html('<a type="button" class="btn btn-link" href="./user.do?action=updateuser$id="+data1[i].id>修改</a><a type="button" class="btn btn-link" href="./user.do?action=deleteuser$id="+data1[i].id>删除</a>');

					}
				}
			});
		})
	})
</script>
</html>
